package per.sunmes.lesrb.actor;

import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.scenes.scene2d.Actor;

public class ShadowActor extends Actor {

	Actor target;
	float tX, tY, tWidth, tHeight, tOrignX, tOrignY, tScaleX, tScaleY, tRotation;
	Color tColor = new Color();

	public ShadowActor(Actor target) {
		this.target = target;
		setSize(target.getWidth(), target.getHeight());
	}

	public Actor getTarget() {
		return target;
	}

	public void setTarget(Actor target) {
		this.target = target;
	}

	public void switchTarget() {
		tX = target.getX();
		tY = target.getY();
		tWidth = target.getWidth();
		tHeight = target.getHeight();
		tOrignX = target.getOriginX();
		tOrignY = target.getOriginY();
		tScaleX = target.getScaleX();
		tScaleY = target.getScaleY();
		tRotation = target.getRotation();
		tColor.set(target.getColor().r, target.getColor().g, target.getColor().b, target.getColor().a);

		target.setPosition(getX(), getY());
		target.setSize(getWidth(), getHeight());
		target.setOrigin(getOriginX(), getOriginY());
		target.setScale(getScaleX(), getScaleY());
		target.setRotation(getRotation());
		target.setColor(getColor());
	}

	public void switchBack() {
		target.setPosition(tX, tY);
		target.setSize(tWidth, tHeight);
		target.setOrigin(tOrignX, tOrignY);
		target.setScale(tScaleX, tScaleY);
		target.setRotation(tRotation);
		target.setColor(tColor.r, tColor.g, tColor.b, tColor.a);
	}

	@Override
	public void draw(Batch batch, float parentAlpha) {
		switchTarget();
		target.draw(batch, parentAlpha);
		switchBack();
	}

}
